//
//  WATFPrivacyViewController.swift
//  WiFiFaster
//
//  Created by one on 2024/1/3.
//

import UIKit
import WebKit

class WATFPrivacyViewController: WATFBaseViewController , WKNavigationDelegate {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        view.addSubview(watf_navView)
        view.addSubview(watf_wkView)
        view.addSubview(watf_loading)
        
        watf_wkView.snp.makeConstraints { make in
            make.bottom.width.leading.equalToSuperview()
            make.top.equalTo(watf_navView.snp.bottom)
        }
        
        watf_loading.snp.makeConstraints { make in
            make.size.equalTo(110)
            make.centerX.centerY.equalToSuperview()
        }
    }
    
    //MARK: - watf action
    func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
        watf_loading.startAnimating()
    }
    
    func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
        watf_loading.stopAnimating()
    }
    
    func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
        watf_loading.stopAnimating()
    }
    
    //MARK: - watf lazy
    lazy var watf_navView: WATFNavView = {
        let watf_navView = WATFNavView()
        return watf_navView
    }()
    
    
    lazy var watf_wkView: WKWebView = {
        let watf_wkView = WKWebView()
        watf_wkView.load(URLRequest.init(url: URL.init(string: "https://sites.google.com/view/fgdbxbrth/")!))
        watf_wkView.navigationDelegate = self
        return watf_wkView
    }()
    
    lazy var watf_loading: UIActivityIndicatorView = {
        let watf_loading = UIActivityIndicatorView()
        if #available(iOS 13.0, *) {
            watf_loading.style = UIActivityIndicatorView.Style.medium
        } else {
            watf_loading.style = UIActivityIndicatorView.Style.gray
        }
        return watf_loading
    }()
    
}
